#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

struct Action {
    int start;
    int end;

    friend ostream &operator<<(ostream &os, const Action &a) {
        os << "[" << a.start << "," << a.end << "]";
        return os;
    }

//    friend bool operator<(const Action a, const Action b) {
//        return a.start < b.start;
//    }
    bool operator<(const Action &that) const {
        // return this->end - this->start < that.end - that.start;//短任务优先
        // return this->start<that.start;//起点优先 适合字少会场满足所有的他人
        return this->end < that.end;//越早结束优先 适合单一会场满足最多的相容会议
    }

} a[10000];

int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    freopen("greedy.in", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].start >> a[i].end;
    }

    sort(a, a + n);
    int start = 0;
    for (int i = 0; i < n; i++) {
        if (a[i].start >= start) {
            cout << a[i];
            start = a[i].end;
        }
    }

    return 0;
}
